home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / DebugTool_111.lha / srcvars.c < prev    next >
C/C++ Source or Header  |  1992-10-31  |  2KB  |  97 lines

  1. #include "frobnitz.h"
  2.  
  3. /*******************************************************************/
  4. /*  Funktion: PrintVars                                            */
  5. /*******************************************************************/
  6.  
  7. void
  8. PrintVars (void)
  9. {
  10.   unsigned short int i;
  11.   unsigned short int variable[256];
  12.   unsigned short int max_glob, beg, end;
  13.   byte temp, try_it = 0;
  14.  
  15.   max_glob = ((header.variable_offset < header.object_offset) ? (header.object_offset - header.variable_offset) : (header.save_area_size - header.variable_offset));
  16.   max_glob /= 2;
  17.  
  18.   printf ("GLOBAL VARIABLES:\n\n");
  19.  
  20.   printf ("Number of globals: ");
  21.  
  22.   if (max_glob > 240)
  23.     {
  24.       try_it = 1;
  25.       max_glob = 240;
  26.     }
  27.   else
  28.     printf ("%d", max_glob);
  29.  
  30.   seek_pos (header.variable_offset);
  31.  
  32.   beg = ftell (DatFile) - header_level * 512;
  33.  
  34.   for (i = 16; i <= (max_glob + 15); i++)
  35.     {
  36.       variable[i] = fgetc (DatFile) * 0x100 + fgetc (DatFile);
  37.     }
  38.  
  39.   end = ftell (DatFile) - header_level * 512;
  40.  
  41.   if (try_it == 1)
  42.     {
  43.       for (i = 16; i <= (max_glob + 15); i++)
  44.     {
  45.       if ((variable[i] > beg) && (variable[i] < beg + (max_glob * 2)))
  46.         {
  47.           max_glob = (variable[i] - beg) / 2;
  48.         }
  49.     }
  50.       printf ("%d", max_glob);
  51.     }
  52.  
  53.   newline ();
  54.  
  55. #ifdef DEBUG
  56.   printf ("<V-BEG:$%04x>\n", beg);
  57. #endif
  58.  
  59. #ifdef DEBUG
  60.   printf ("<V-END:$%04x>\n", beg + (max_glob * 2));
  61. #endif
  62.  
  63.   for (i = 16; i <= (max_glob + 15); i++)
  64.     {
  65.       if (dec_enum)
  66.     printf ("%4d :  %5d", i - 16, variable[i]);
  67.       else
  68.     printf ("$%3x :  $%4x", i - 16, variable[i]);
  69.  
  70.       if (header.z_version == 3)
  71.     {
  72.       if (i == 16)
  73.         {
  74.           printf (" [Location:");
  75.  
  76.           if (variable[i] == 0)
  77.         printf ("<none>");
  78.           else
  79.         {
  80.           temp = no_enum;
  81.           no_enum = 1;
  82.           PrintObject ((int) (variable[i] - 1));
  83.           no_enum = temp;
  84.         }
  85.  
  86.           printf ("]");
  87.         }
  88.       if (i == 17)
  89.         printf (" [Score/Hours]");
  90.       if (i == 18)
  91.         printf (" [Moves/Minutes]");
  92.     }
  93.  
  94.       newline ();
  95.     }
  96. }
  97.